export class UniformSampler {
    name: any;
    value: any = undefined;
    _gl: any;
    _location: any;
    textureUnitIndex: any = undefined
    constructor(gl: any, activeUniform: any, private uniformName: any, location: any) {
        this._gl = gl;
        this.name = uniformName;
        this._location = location
    }
    _setSampler = (textureUnitIndex: any) => {
        this.textureUnitIndex = textureUnitIndex;
        this._gl.uniform1i(this._location, textureUnitIndex);
        return textureUnitIndex + 1;
    };
    set = () => {
        const gl = this._gl;
        gl.activeTexture(gl.TEXTURE0 + this.textureUnitIndex);

        const v = this.value;
        gl.bindTexture(v._target, v._texture);
    };
}
export class UniformArraySampler {
    name: any;
    value: any = undefined;
    _value: any = undefined;
    _gl: any;
    _locations: any;
    textureUnitIndex: any = undefined
    constructor(gl: any, activeUniform: any, private uniformName: any, locations: any) {
        const length = locations.length;
        this._gl = gl;
        this.value = new Array(length)
        this._value = new Float32Array(length);
        this.name = uniformName;
        this._locations = locations
        this.textureUnitIndex = undefined;
    }
    _setSampler = (textureUnitIndex: any) => {
        this.textureUnitIndex = textureUnitIndex;

        const locations = this._locations;
        const length = locations.length;
        for (let i = 0; i < length; ++i) {
            const index = textureUnitIndex + i;
            this._gl.uniform1i(locations[i], index);
        }

        return textureUnitIndex + length;
    };
    set = () => {
        const gl = this._gl;
        const textureUnitIndex = gl.TEXTURE0 + this.textureUnitIndex;

        const value = this.value;
        const length = value.length;
        for (let i = 0; i < length; ++i) {
            const v = value[i];
            gl.activeTexture(textureUnitIndex + i);
            gl.bindTexture(v._target, v._texture);
        }
    };
}